Re: [GENERAL] PL/PGSQL - Mailing list pgsql-general

From Herouth Maoz
Subject Re: [GENERAL] PL/PGSQL
Date
Msg-id l03130300b3e6c1277135@[147.233.159.109]
Whole thread Raw
In response to PL/PGSQL  (Jens Felber <jfe@gek-online.de>)
List pgsql-general
At 10:17 +0300 on 23/08/1999, Jens Felber wrote:

> On every time, when my trigger is called  I get
> the Message:
>
> ERROR: fmgr_info: function 87776 : cache lookup failure
>
> What means this - or where are described ERROR-Messages at the Documentation.
>
> What I've done:
>
> create table test1 (x int2, free bool);
> create table history (x
> int2);
>
> create function insert_history () returns opaque as
>     'select x into history from test1 where free=\'t\';'
> language 'plpgsql';
>
> create trigger ins1 after update on test1 for each row execute procedure
> insert_history();

I'm not sure the above is a legal plpgsql procedure. Looks more like sql
than anything procedural. One thing I'm sure is that it isn't what you
wanted to do. SELECT INTO creates a new table, so if the table exists, it
won't work. The way to populate an existing table with values from another
table is

INSERT INTO history
SELECT x
FROM test1
WHERE free;

(Note that you don't have to compare booleans... It's redundant. You can
just use them directly. But that's just a side comment. Saves you on those
escaped quotes).

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma



pgsql-general by date:

Previous
From: Jens Felber
Date:
Subject: PL/PGSQL
Next
From: "Hub.Org News Admin"
Date:
Subject: ...